package com.iknow.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask.Status;
import android.os.Bundle;
import android.widget.Button;
import com.iknow.IKnow;
import com.iknow.app.IKnowSystemConfig;
import com.iknow.data.QingBo;
import com.iknow.db.IKnowDataBase;
import com.iknow.task.CommonTask.QingboTask;
import com.iknow.task.TaskParams;
import com.iknow.util.StringUtil;
import com.iknow.view.widget.PullToRefreshListView;
import com.iknow.xmpp.service.Friend;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class FriendQingboActivity extends QingboWithNoHeaderActivity
{
  private Friend mContact;

  List<QingBo> doGetLocolData()
  {
    return IKnow.mIKnowDataBase.getFriendQingbo(this.mLocalOffset, 20, this.mAuthorID);
  }

  void doNeedMore()
  {
    if ((this.mTask != null) && (this.mTask.getStatus() == AsyncTask.Status.RUNNING));
    while (true)
    {
      return;
      this.mGetMoreButton.setText("正在载入数据...");
      String str = IKnow.mSystemConfig.getString(this.TAG);
      this.mTask = new CommonTask.QingboTask();
      this.mTask.setListener(this.mGetMoreListener);
      TaskParams localTaskParams = new TaskParams();
      localTaskParams.put("create_user", this.mAuthorID);
      localTaskParams.put("offset", Integer.valueOf(0));
      localTaskParams.put("length", Integer.valueOf(20));
      localTaskParams.put("page_type", Integer.valueOf(1));
      if (!(StringUtil.isEmpty(str)))
        this.mListView.setLastUpdated("更新于" + str);
      long l = IKnow.mIKnowDataBase.getFriendQingboMinTime(this.mAuthorID, "owner");
      if (0L != l)
        localTaskParams.put("create_time_end", this.mDateFormat.format(new Date(l)));
      CommonTask.QingboTask localQingboTask = this.mTask;
      TaskParams[] arrayOfTaskParams = new TaskParams[1];
      arrayOfTaskParams[0] = localTaskParams;
      localQingboTask.execute(arrayOfTaskParams);
    }
  }

  void getServerData()
  {
  }

  protected void onCreate(Bundle paramBundle)
  {
    String str;
    super.onCreate(paramBundle);
    this.PAGE_TYPE = 1;
    Activity localActivity = getParent();
    if (localActivity instanceof FriendInfoActivity)
    {
      this.mContact = ((Friend)localActivity.getIntent().getParcelableExtra("friend"));
      str = localActivity.getIntent().getStringExtra("friendID");
      if (this.mContact == null)
        break label100;
      this.TAG = this.mContact.getID() + "_FriendQingboActivity";
      this.mAuthorID = this.mContact.getID();
    }
    while (true)
    {
      getLocolData();
      return;
      label100: this.TAG = str + "_FriendQingboActivity";
      this.mAuthorID = str;
    }
  }

  void refreshData()
  {
    if ((this.mTask != null) && (this.mTask.getStatus() == AsyncTask.Status.RUNNING))
      return;
    String str = IKnow.mSystemConfig.getString(this.TAG);
    this.mTask = new CommonTask.QingboTask();
    this.mTask.setListener(this.mTaskListener);
    this.mTask.setAdapter(this.mAdapter);
    TaskParams localTaskParams = new TaskParams();
    if (this.mContact != null)
      localTaskParams.put("create_user", this.mAuthorID);
    while (true)
    {
      while (true)
      {
        localTaskParams.put("offset", Integer.valueOf(0));
        localTaskParams.put("length", Integer.valueOf(20));
        localTaskParams.put("page_type", Integer.valueOf(1));
        if (!(StringUtil.isEmpty(str)))
          this.mListView.setLastUpdated("更新于" + str);
        long l = IKnow.mIKnowDataBase.getFriendQingboMaxTime(this.mAuthorID, "owner");
        if (0L != l)
          localTaskParams.put("create_time_start", this.mDateFormat.format(new Date(l)));
        CommonTask.QingboTask localQingboTask = this.mTask;
        TaskParams[] arrayOfTaskParams = new TaskParams[1];
        arrayOfTaskParams[0] = localTaskParams;
        localQingboTask.execute(arrayOfTaskParams);
      }
      localTaskParams.put("create_user", this.mAuthorID);
    }
  }
}